﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace WindowsFormsApplication2
{
    public partial class AnimationEditor : Form
    {
        private Form1 Form1Parent;
        private String EditName;


        public AnimationEditor()
        {
            throw new Exception("Animation Editor Called with no Parent.");
        }

        public AnimationEditor(Form1 Form1Parent)
        {
            InitializeComponent();

            this.Form1Parent = Form1Parent;
            EditName = null;
        }

        public AnimationEditor(Animation CurrentAnimation, Form1 Form1Parent)
        {
            InitializeComponent();
            this.Form1Parent = Form1Parent;

            nameTextBox.Text = CurrentAnimation.Name;
            srowTextBox.Text = CurrentAnimation.StartRow.ToString();
            erowTextBox.Text = CurrentAnimation.EndRow.ToString();
            scolTextBox.Text = CurrentAnimation.StartCol.ToString();
            ecolTextBox.Text = CurrentAnimation.EndCol.ToString();
            oscillatesCheckBox.Checked = CurrentAnimation.Oscilate;
            EditName = CurrentAnimation.Name;
        }

        private void cancelButton_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void doneButton_Click(object sender, EventArgs e)
        {
            try
            {
                Animation temp = new Animation(nameTextBox.Text,
                    Convert.ToInt32(scolTextBox.Text), Convert.ToInt32(ecolTextBox.Text),
                    Convert.ToInt32(srowTextBox.Text), Convert.ToInt32(erowTextBox.Text),
                    oscillatesCheckBox.Checked);
                Form1Parent.AddReplaceAnimation(EditName, nameTextBox.Text, temp);

                this.Close();
            }
            catch (Exception)
            {
                MessageBox.Show("Make Sure your input is int the correct format.", "Input Error",
                MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
        }
    }
}
